package com.sgcc.activiti.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.activiti.domain.OContentAdPic;
import com.sgcc.activiti.service.IOContentAdPicService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 广告图片Controller
 * 
 * @author sgcc
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/OContentAdPic")
public class OContentAdPicController extends BaseController
{
    @Autowired
    private IOContentAdPicService oContentAdPicService;

    /**
     * 查询广告图片列表
     */
    //@PreAuthorize(hasPermi = "activiti:OContentAdPic:list")
    @GetMapping("/list")
    public TableDataInfo list(OContentAdPic oContentAdPic)
    {
        startPage();
        List<OContentAdPic> list = oContentAdPicService.selectOContentAdPicList(oContentAdPic);
        return getDataTable(list);
    }

    /**
     * 导出广告图片列表
     */
    //@PreAuthorize(hasPermi = "activiti:OContentAdPic:export")
    @Log(title = "广告图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OContentAdPic oContentAdPic) throws IOException
    {
        List<OContentAdPic> list = oContentAdPicService.selectOContentAdPicList(oContentAdPic);
        ExcelUtil<OContentAdPic> util = new ExcelUtil<OContentAdPic>(OContentAdPic.class);
        util.exportExcel(response, list, "OContentAdPic");
    }

    /**
     * 获取广告图片详细信息
     */
    //@PreAuthorize(hasPermi = "activiti:OContentAdPic:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(oContentAdPicService.selectOContentAdPicById(id));
    }

    /**
     * 新增广告图片
     */
    //@PreAuthorize(hasPermi = "activiti:OContentAdPic:add")
    @Log(title = "广告图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OContentAdPic oContentAdPic)
    {
        return toAjax(oContentAdPicService.insertOContentAdPic(oContentAdPic));
    }

    /**
     * 修改广告图片
     */
    //@PreAuthorize(hasPermi = "activiti:OContentAdPic:edit")
    @Log(title = "广告图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OContentAdPic oContentAdPic)
    {
        return toAjax(oContentAdPicService.updateOContentAdPic(oContentAdPic));
    }

    /**
     * 删除广告图片
     */
    //@PreAuthorize(hasPermi = "activiti:OContentAdPic:remove")
    @Log(title = "广告图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(oContentAdPicService.deleteOContentAdPicByIds(ids));
    }
}
